﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System.Collections.ObjectModel;

namespace RoboTrocity {
	class GraphicsDispenser {
		static Dictionary<String, Texture2D> textures = new Dictionary<String, Texture2D>();
		private static Dictionary<String, SpriteFont> fonts = new Dictionary<String, SpriteFont>();

		public static void initialize() {
			textures = new Dictionary<String, Texture2D>(); 
		}

		public static void addNullTexture(string _textureName) {
			addTexture(_textureName, null);
		}

		public static void addTexture(string _textureName, Texture2D _texture) {
			if (getTexture(_textureName) == null) {
				textures.Add(_textureName, _texture);
			}	
		}

		public static void removeTexture(string _textureName) {
			textures.Remove(_textureName);
		}

		public static void loadTexture(string _textureName, Texture2D _texture) {
			textures[_textureName] = _texture;
		}

		public static Texture2D getTexture(string _textureName) {
			Texture2D returnTexture;
			textures.TryGetValue(_textureName, out returnTexture);
			return returnTexture;
		}

		public static Dictionary<String, Texture2D>.KeyCollection TextureNames {
			get { return textures.Keys; }
		}

		public static Dictionary<String, Texture2D>.ValueCollection Textures {
			get { return textures.Values; }
		}

		#region Fonts

		public static void AddFont(string fontName, SpriteFont sFont) {
			if (GetFont(fontName) == null) {
				fonts.Add(fontName, sFont);
			}	
		}

		public static SpriteFont GetFont(string fontName) {
			SpriteFont returnFont;
			fonts.TryGetValue(fontName, out returnFont);
			return returnFont;
		}

		#endregion
	}
}
